//
//  UITableView+EmptyData.m
//  HuanXin
//
//  Created by 大展 on 15/11/27.
//  Copyright © 2015年 大展. All rights reserved.
//

#import "UITableView+EmptyData.h"


@implementation UITableView (EmptyData)

- (NSInteger)tableViewDisplayMessage:(NSString *)message withSourceCount:(NSInteger)count {
    
    if (count == 0) {
        
        UILabel * messageLabel = [[UILabel alloc]init];
        messageLabel.text = message;
        messageLabel.textAlignment = NSTextAlignmentCenter;
        messageLabel.textColor = [UIColor lightGrayColor];
        self.backgroundView = messageLabel;
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        
    } else {
        
        self.backgroundView = nil;
        self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    }
    return count;
}


- (NSInteger)tableViewDisplayImage:(UIImage *)image withSourceCount:(NSInteger)count {
    
    if (count == 0) {
        
        UIImageView * imageView = [[UIImageView alloc]initWithImage:image];
        self.backgroundView = imageView;
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        
    } else {
        
        self.backgroundView = nil;
        self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    }
    return count;

}
@end
